package org.csu.laboratoryequipment.common;

import lombok.Getter;
import org.springframework.hateoas.Link;

import java.io.Serializable;
import java.util.List;

@Getter
public class CommonResponse<T> implements Serializable {
    private int status;
    private String mag;
    private T data;

    private CommonResponse(int status)
    {
        this.status = status;
    }
    private CommonResponse(int status,String msg)
    {
        this.status = status;
        this.mag = msg;
    }
    private CommonResponse(int status,T data)
    {
        this.status = status;
        this.data = data;
    }
    private CommonResponse(String msg,T data)
    {
        this.mag = msg;
        this.data = data;
    }
    private CommonResponse(int status,String msg,T data)
    {
        this.status = status;
        this.mag = msg;
        this.data = data;
    }


    public static <T> CommonResponse<T> createForSuccess()
    {
        return new CommonResponse<T>(ResponseCode.SUCCESS.getCode());
    }
    public static <T> CommonResponse<T> createForSuccess(T data)
    {
        return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(),data);
    }

    public static <T> CommonResponse<T> createForSuccessMessage(String msg)
    {
        return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(),msg);
    }
    public static <T> CommonResponse<T> createForSuccessMessage(String msg,T data)
    {
        return new CommonResponse<T>(ResponseCode.SUCCESS.getCode(),msg,data);
    }


    public static <T> CommonResponse<T> createForError()
    {
        return new CommonResponse<T>(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDescription());
    }
    public static <T> CommonResponse<T> createForError(int code)
    {
        return new CommonResponse<T>(code,ResponseCode.ERROR.getDescription());
    }
    public static <T> CommonResponse<T> createForSuccess(int code)
    {
        return new CommonResponse<T>(code,ResponseCode.SUCCESS.getDescription());
    }


}
